package com.bwie.auth.controller;

import com.bwie.auth.service.AuthService;
import com.bwie.common.domain.User;
import com.bwie.common.domain.response.JwtResponse;
import com.bwie.common.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/auth")
public class AuthController {
    @Autowired
    private AuthService authService;

    /**
     * 登录
     */
    @PostMapping("/login")
    public Result<JwtResponse> login(@RequestBody User user){
        JwtResponse jwtResponse = authService.login(user);
        return Result.success(jwtResponse);
    }
    /**
     * 获取个人信息
     */
    @GetMapping("/user/info")
    public Result<User> userInfo(){
        User user = authService.userInfo();
        return Result.success(user);
    }
    /**
     * 退出
     */
    @GetMapping("/user/logout")
    public Result userLogout(){
        authService.userLogout();
        return Result.success();
    }
}
